﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class TJLVK05QA
    {
        public TJLVK05QA()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return; 
            MV = new VVKPOS();
            DataContext = MV;  
            InitializeComponent();
            ART = "J" + MV.year.Substring(3, 1) + "-";
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            //base.vwMaster_CurrentChanged(sender, e);            
            if (dwMaster != null)
            {
                PRART = dwMaster["VKPMANDANT"].ToString() + dwMaster["VKPKOLL"].ToString() + dwMaster["VKPART"].ToString() + dwMaster["VKPFARBE"].ToString(); 
                KEY = dwMaster["ROWNID"].ToString();             
            }
            else
            {
                KEY = "";
                PRART = "0";
            }
        }

        public override void QueryCommand(object sender, System.Windows.RoutedEventArgs e)
        {
            if (ART.Trim().Length < 1)
            {
                MessageBox.Show("请输入查询条件!");
                return;
            }
            dwData = TBMain.NewRow();
            dwData["VKPMANDANT"] = app.Mandant;
            dwData["VKPART"] = ART.Trim();
            SResult = TMV.QVKP25(dwData);
            MergeData(SResult, false);
            base.QueryCommand(sender, e);
        }
        private void ART_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            try
            {
                if (e.Key != System.Windows.Input.Key.Enter)
                    return;
                this.Focus();
                QueryCommand(sender, null);
                txtART.Focus();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }

        }
    }
}
